//package com.platform.config;
//
//import com.platform.common.utils.StringUtils;
//import com.wechat.pay.java.core.Config;
//import com.wechat.pay.java.core.RSAAutoCertificateConfig;
//import com.wechat.pay.java.core.http.DefaultHttpClientBuilder;
//import com.wechat.pay.java.core.http.HttpClient;
//import com.wechat.pay.java.service.cashcoupons.CashCouponsService;
//import lombok.AllArgsConstructor;
//import me.chanjar.weixin.mp.api.WxMpService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.context.properties.EnableConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import java.net.InetSocketAddress;
//import java.net.Proxy;
//
///**
// * @author Admin
// */
//@AllArgsConstructor
//@Configuration
//@EnableConfigurationProperties(WxPayProperties.class)
//public class CouponConfiguration {
//    private WxPayProperties properties;
//    @Bean
//    public CashCouponsService couponsService(){
//        return new CashCouponsService.Builder().config(config()).httpClient(httpClient()).build();
//    }
//
//    @Bean
//    public Config config(){
//        return new RSAAutoCertificateConfig.Builder()
//                .merchantId(properties.getMchId())
//                .privateKeyFromPath(properties.getKeyPath())
//                .merchantSerialNumber(properties.getMchSerialNo())
//                .apiV3Key(properties.getMchKey())
//                .build();
//    }
//    @Bean
//    public HttpClient httpClient(){
//        HttpClient httpClient;
//        if(StringUtils.isNotBlank(properties.getProxyIp())){
//            Proxy proxy = new Proxy(Proxy.Type.HTTP,new InetSocketAddress(properties.getProxyIp() , properties.getProxyPort()));
//            httpClient = new DefaultHttpClientBuilder().config(config()).proxy(proxy).build();
//        }else {
//            httpClient = new DefaultHttpClientBuilder().config(config()).build();
//        }
//        return httpClient;
//    }
//}
